package controller;

import com.alibaba.fastjson.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pojo.Student;
import service.StudentService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
public class StudentController {

    @Autowired
    //多个实现类时用的注解@Qualifier()
    StudentService studentService;

    @RequestMapping(value = "index",produces = "application/json",method = RequestMethod.GET)
    public List<Student> findStudentAll(HttpServletRequest request, HttpServletResponse response) throws IOException {
           List<Student> list= studentService.findStudentAll();
        if(list == null || list.size() <= 0){
           return null;
        }else{
            return list;
        }
    }
}
